/* ================================================================
*   Copyright (C) 2020 All rights reserved.
*
*   文件名称：write_example.cpp
*   创 建 者：xunmenglong
*   创建日期：2020年12月06日
*   描    述：
*
================================================================ */


#ifndef WRITE_EXAMPLE_CPP
#define WRITE_EXAMPLE_CPP

#include "xkvstore.h"

int main(int argc, char ** argv) {
    xkvstore kv;
    int ret = kv.init("./data");
    if (ret != 0) {
        LOG(ERROR) << "xkvstore init fail";
        return -1;
    }
    string values[5] = {"xkvstore", "is", "a", "good", "store"};
    for (int i=0; i<5; i++) {
        int key = 10000+i;
        ret = kv.set(key, values[i].c_str(), values[i].size()+1);
        if (ret != 0) {
            LOG(ERROR) << "set value fail";
            return -1;
        }
    }
    char result[1024];
    strcpy(result, "hello world");
    kv.set(11111, result, strlen(result)+1);
    LOG(NOTICE) << "write succ";
    return 0;
}

#endif
